<?php
define('APP','./Application');
define('VIEW',APP.'/Views');

require_once './Core/Lib/Common.php';
include(APP.'/Conf/common.config.php');
/*路由解析*/
$SystemConfig = include(APP.'/Conf/system.config.php');
$path = $_GET;
$path['GROUP'] = $SystemConfig['DEFAULT_GROUP'];
$path['CONTROLLER'] = $SystemConfig['DEFAULT_CONTROLLER'];
$path['FUNCTION'] = $SystemConfig['DEFAULT_FUNCTION'];
if(isset($path['s'])){
	$pathArr = explode("/",$path['s']);
	if(count($pathArr) == 3){
		$path['GROUP'] = $pathArr[0];
		$path['CONTROLLER'] = $pathArr[1];
		$path['FUNCTION'] = $pathArr[2];		
	}
	if(count($pathArr) == 2){
		$path['CONTROLLER'] = $pathArr[0];
		$path['FUNCTION'] = $pathArr[1];		
	}
	
}
//错误开关
if(!$SystemConfig['APP_DEBUG']){
	error_reporting(0);
}

//类自动加载
function __autoload($className){
	$group = '';
	if(strpos($className,'__')){
		$pathBreak = explode('__',$className);
		$group = $pathBreak[0].'/';
		$className = $pathBreak[1];
		$file_path = APP.'/Controller/'.$group.$className.'.class.php';
	}else{
		$file_path = './Core/Lib/CTCF/Controller.class.php';
	}
	if(file_exists($file_path)){
		include_once $file_path;
	}else{
		exit($file_path.' not find');
	}
}


$ctl = $path['GROUP'].'__'.$path['CONTROLLER'].'Controller';
$controller=new $ctl($SystemConfig['RUN_MODEL']);
$controller->$path['FUNCTION']();